﻿using DailyApp.WPF.MsgEvents;
using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DailyApp.WPF.Views
{
    /// <summary>
    /// LoginUC.xaml 的交互逻辑
    /// </summary>
    public partial class LoginUC : UserControl
    {
        //发布订阅
        private readonly IEventAggregator eventAggregator;

        public LoginUC(IEventAggregator _eventAggregator)
        {
            InitializeComponent();

            this.eventAggregator = _eventAggregator;

            //订阅
            eventAggregator.GetEvent<MsgEvent>().Subscribe(Sub);
        }

        /// <summary>
        /// 订阅的方法-委托
        /// </summary>
        /// <param name="obj">接收的信息</param>
        private void Sub(string obj)
        {
            //想做的事情
            this.RegLogBar.MessageQueue?.Enqueue(obj);
        }


        //拖动窗体
        private void MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            // 获取父窗口并拖动
            var window = Window.GetWindow(this); // 如果当前是窗口，直接写 this.DragMove()
            window?.DragMove();
        }
    }
}
